#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<cstdlib>
#include<cmath>
#include<sstream>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<stack>
#define PI acos(-1)
#define MP make_pair
#define PB push_back
#define VI vector <int>
#define PII pair <int,int>
#define LL long long
#define SET(v,i) memset(v, i, sizeof(v))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define FORN(i,a,b) for (int i = (a); i < (b); i++)
#define DOWN(i,a,b) for (int i = (a); i > (b); i--)
#define FIT(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); it++)
#define FITD(it,v) for (typeof(v.rbegin()) it = v.rbegin(); it != v.rend(); it++)
using namespace std;
const int N=100001;
vector<int>v[N];
int a[N],n,dp[N];
const vector<int> & init(int x){
	if(v[x].size())return v[x];
	int t=x;
	for(int i=2;i*i<=t;i++)if(t%i==0){
		v[x].push_back(i);while(t%i==0)t/=i;
		}
	if(t>1)v[x].push_back(t);
	return v[x];
	}
int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		for(int i=0;i<n;i++)scanf("%d",&a[i]),v[a[i]].clear();
		memset(dp,0,sizeof(dp));
		int bns=1;
		for(int i=0;i<n;i++)if(a[i]>1){
			vector<int> e=init(a[i]);
			int ans=1;
			for(vector<int>::iterator it=e.begin();it!=e.end();++it)ans=max(ans,dp[*it]+1);
			for(vector<int>::iterator it=e.begin();it!=e.end();++it)dp[*it]=max(dp[*it],ans);
			bns=max(bns,ans);
			}
		cout<<bns<<endl;
		}
    return 0;
    }
